check if date is older than today php

120

<?php
 $date_now = new DateTime();
 $date2    = new DateTime("01/02/2016");

if ($date_now > $date2) {
    echo 'greater than';
}else{
    echo 'Less than';
}
<?php
 $date_now = date("Y-m-d"); // this format is string comparable

if ($date_now > '2016-01-02') {
    echo 'greater than';
}else{
    echo 'Less than';
}
 if(strtotime('2011-08-19 17:14:40') < strtotime('-30 days')) {
     // this is true
 }

Comments

Submit
0 Comments